package com.huangsm.book.designmodel.reference;

import javax.swing.plaf.synth.SynthCheckBoxUI;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;

/**
 * @author huang
 * @PACKAGE_NAME com.huangsm.book.designmodel.reference
 * @PROJECT_NAME concurrence
 * @date 2019/2/18
 */
public class MyObject {
    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        System.out.println("myobject's finalize called");
    }

    @Override
    public String toString() {
        return "I am MyObject";
    }

    public static void main(String[] args) {
        MyObject myObject=new MyObject(); //    强引用
        ReferenceQueue<MyObject> softQueue = new ReferenceQueue<MyObject>();//创建引用队列
        SoftReference<MyObject> softRef = new SoftReference<>(myObject, softQueue);//创建软引用

    }
}
